if !SERVER then return end
-- List of conVars:
-- 
-- "pdmg_enabled" = "1"
--      - Enable(1)/Diable(0) Prop_Damage Addon
--
-- "pdmg_death_effect" = "cball_explode"
--      - Effect Played when Props are Destroyed, '' Disables
-- 
-- "pdmg_ragdoll_health" = "5000"
--      - Ragdoll Health Fix (They Die Too Easy), 0 Disables
-- 	 
-- "pdmg_override_health" = "0" ( def. "0" )
--      - Override Health Calculations Completely and Just use x Health for all new Props, 0 Disables
-- 	 
-- "pdmg_use_volume" = "1"
--      - Enable(1)/Disable(0) Using Volume in Prop_Damage Calculations
--  
-- "pdmg_use_mass" = "1"
--      - Enable(1)/Disable(0) Using Mass in Prop_Damage Calculations
--  
-- "pdmg_autoheal" = "0"
--      - Disable(0) All other values heal props every x seconds where x = pdmg_autoheal_interval
--  
-- "pdmg_autoheal_interval" = "1"
--      - Interval for prop autohealing 0 is constant
--  
-- "pdmg_autoheal_players" = "0"
--      - Disable(0) All other values heal players every x seconds where x = pdmg_autoheal_players_interval
--  
-- "pdmg_autoheal_players_interval" = "1"
--      - Interval for players autohealing 0 is constant
--  
-- "pdmg_autoheal_npcs" = "0"
--      - Disable(0) All other values heal npcs every x seconds where x = pdmg_autoheal_npcs_interval
--  
-- "pdmg_autoheal_npcs_interval" = "1"
--      - Interval for npc autohealing 0 is constant
--  
-- "pdmg_breakconstraints" = "0"
--      - Enable(1)/Disable(0) Break Constraints on low health
--  
-- "pdmg_breakconstraints_percent" = "0.1"
--      - Percent at which constraints break in decimal.
--  
-- "pdmg_unfreeze" = "0"
--      - Enable(1)/Disable(0) Unfreeze prop on low health
--  
-- "pdmg_unfreeze_percent" = "0.2"
--      - Percent at which to unfreeze
--  
-- "pdmg_color_damage" = "0"
--      - Color's props red based on damage.
--  
-- "pdmg_health_multiplier" = "0"
--      - Multiplies all props health by this amount 0 - 1000
-- "pdmg_props_only" = "0"
--      - If set to 1 this disables health for all non prop_physics
-- "pdmg_ex_wire" = 0
--      - If set to 1 this disables health for wire classes
-- "pdmg_ex_stargate" = 1
--	    - If set to 1 this disables health for stargate classes
-- "pdmg_ex_gmod" = 0 
--      - If set to 1 this disables health for gmod classes
-- "pdmg_ex_phx_exp" = 1
--      - If set to 1 this disables health for phx explosives
-- "pdmg_ex_hl2_exp" = 1
--      - If set to 1 this disables health for hl2 explosives

-- Create Con Vars to handle Options
if !ConVarExists("pdmg_enabled") then
	CreateConVar("pdmg_enabled", '1', {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Enable(1)/Disable(0) Prop_Damage Addon")
else
	local conTemp = GetConVar("pdmg_enabled")
	CreateConVar("pdmg_enabled", conTemp:GetInt(), {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Enable(1)/Disable(0) Prop_Damage Addon")
end

if !ConVarExists("pdmg_use_mass") then
	CreateConVar("pdmg_use_mass", '1',  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Enable(1)/Disable(0) Using Mass in Prop_Damage Calculations")
else
	local conTemp = GetConVar("pdmg_use_mass")
	CreateConVar("pdmg_use_mass", conTemp:GetInt(),  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Enable(1)/Disable(0) Using Mass in Prop_Damage Calculations")	
end

if !ConVarExists("pdmg_use_volume") then
	CreateConVar("pdmg_use_volume", '1',  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Enable(1)/Disable(0) Using Volume in Prop_Damage Calculations")
else
	local conTemp = GetConVar("pdmg_use_volume")
	CreateConVar("pdmg_use_volume", conTemp:GetInt(),  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Enable(1)/Disable(0) Using Volume in Prop_Damage Calculations")	
end

if !ConVarExists("pdmg_override_health") then
	CreateConVar("pdmg_override_health", '0',  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Override Health Calculations Completely and Just use x Health for all new Props, 0 Disables")
else
	local conTemp = GetConVar("pdmg_override_health")
	CreateConVar("pdmg_override_health", conTemp:GetInt(),  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Override Health Calculations Completely and Just use x Health for all new Props, 0 Disables")
end

if !ConVarExists("pdmg_ragdoll_health") then
	CreateConVar("pdmg_ragdoll_health", '5000',  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Ragdoll Health Fix (They Die Too Easy), 0 Disables")
else
	local conTemp = GetConVar("pdmg_ragdoll_health")
	CreateConVar("pdmg_ragdoll_health", conTemp:GetInt(),  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Ragdoll Health Fix (They Die Too Easy), 0 Disables")	
end

if !ConVarExists("pdmg_death_effect") then
	CreateConVar("pdmg_death_effect", 'cball_explode',  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Effect Played when Props are Destroyed, '' Disables")
else
	local conTemp = GetConVar("pdmg_death_effect")
	CreateConVar("pdmg_death_effect", conTemp:GetString(),  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Effect Played when Props are Destroyed, '' Disables")
end

if !ConVarExists("pdmg_autoheal") then
	CreateConVar("pdmg_autoheal", '0',  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Amount to Autoheal props every pdmg_autoheal_interval seconds. 0 Disables")
else
	local conTemp = GetConVar("pdmg_autoheal")
	CreateConVar("pdmg_autoheal", conTemp:GetInt(),  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Amount to Autoheal props every pdmg_autoheal_interval seconds. 0 Disables")
end

if !ConVarExists("pdmg_autoheal_interval") then
	CreateConVar("pdmg_autoheal_interval", '0',  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Autoheal Interval, 0 is constant")
else
	local conTemp = GetConVar("pdmg_autoheal_interval")
	CreateConVar("pdmg_autoheal_interval", conTemp:GetFloat(),  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Autoheal Interval, 0 is constant")
end

if !ConVarExists("pdmg_autoheal_players") then
	CreateConVar("pdmg_autoheal_players", '0',  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Amount to Autoheal players every pdmg_autoheal_players_interval seconds. 0 Disables")
else
	local conTemp = GetConVar("pdmg_autoheal_players")
	CreateConVar("pdmg_autoheal_players", conTemp:GetInt(),  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Amount to Autoheal players every pdmg_autoheal_players_interval seconds. 0 Disables")
end

if !ConVarExists("pdmg_autoheal_players_interval") then
	CreateConVar("pdmg_autoheal_players_interval", '0',  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Autoheal players interval, 0 is constant")
else
	local conTemp = GetConVar("pdmg_autoheal_players_interval")
	CreateConVar("pdmg_autoheal_players_interval", conTemp:GetFloat(),  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Autoheal players interval, 0 is constant")
end

if !ConVarExists("pdmg_autoheal_npcs") then
	CreateConVar("pdmg_autoheal_npcs", '0',  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Amount to Autoheal NPCs every pdmg_autoheal_players_interval seconds. 0 Disables")
else
	local conTemp = GetConVar("pdmg_autoheal_npcs")
	CreateConVar("pdmg_autoheal_npcs", conTemp:GetInt(),  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Amount to Autoheal NPCs every pdmg_autoheal_players_interval seconds. 0 Disables")
end

if !ConVarExists("pdmg_autoheal_npcs_interval") then
	CreateConVar("pdmg_autoheal_npcs_interval", '0',  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Autoheal NPCs interval, 0 is constant")
else
	local conTemp = GetConVar("pdmg_autoheal_npcs_interval")
	CreateConVar("pdmg_autoheal_npcs_interval", conTemp:GetFloat(),  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Autoheal NPCs interval, 0 is constant")
end

if !ConVarExists("pdmg_showhealth") then
	CreateConVar("pdmg_showhealth", '1',  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "0 Disables, 1 All the Time, 2 Only with SWEP")
else
	local conTemp = GetConVar("pdmg_showhealth")
	CreateConVar("pdmg_showhealth", conTemp:GetInt(),  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "0 Disables, 1 All the Time, 2 Only with SWEP")
end

if !ConVarExists("pdmg_breakconstraints") then
	CreateConVar("pdmg_breakconstraints", '1',  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Break Constraints when Health is Low, 1 Activates, 0 Disables")
else
	local conTemp = GetConVar("pdmg_breakconstraints")
	CreateConVar("pdmg_breakconstraints", conTemp:GetInt(),  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Break Constraints when Health is Low, 1 Activates, 0 Disables")
end

if !ConVarExists("pdmg_breakconstraints_percent") then
	CreateConVar("pdmg_breakconstraints_percent", '0.10',  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Break Constraints when heath is x percent, in decimal form.")
else
	local conTemp = GetConVar("pdmg_breakconstraints_percent")
	CreateConVar("pdmg_breakconstraints_percent", conTemp:GetFloat(),  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Break Constraints when heath is x percent, in decimal form.")
end

if !ConVarExists("pdmg_unfreeze") then
	CreateConVar("pdmg_unfreeze", '1',  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Unfreeze Prop when Health is Low, 1 Activates, 0 Disables")
else
	local conTemp = GetConVar("pdmg_unfreeze")
	CreateConVar("pdmg_unfreeze", conTemp:GetInt(),  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Unfreeze Prop when Health is Low, 1 Activates, 0 Disables")
end

if !ConVarExists("pdmg_unfreeze_percent") then
	CreateConVar("pdmg_unfreeze_percent", '0.20',  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Unfreeze Prop when heath is x percent, in decimal form.")
else
	local conTemp = GetConVar("pdmg_unfreeze_percent")
	CreateConVar("pdmg_unfreeze_percent", conTemp:GetFloat(),  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Unfreeze Prop when heath is x percent, in decimal form.")
end

if !ConVarExists("pdmg_color_damage") then
	CreateConVar("pdmg_color_damage", '0',  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Enables or Disable Coloring the Prop when it's damaged.")
else
	local conTemp = GetConVar("pdmg_color_damage")
	CreateConVar("pdmg_color_damage", conTemp:GetInt(),  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Enables or Disable Coloring the Prop when it's damaged.")
end

if !ConVarExists("pdmg_health_multiplier") then
	CreateConVar("pdmg_health_multiplier", '0',  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Multiplyer for prop/npc health.")
else
	local conTemp = GetConVar("pdmg_health_multiplier")
	CreateConVar("pdmg_health_multiplier", conTemp:GetFloat(),  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Multiplyer for prop/npc health.")
end

if !ConVarExists("pdmg_props_only") then
	CreateConVar("pdmg_props_only", '0',  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Enables damage for prop_physics only")
else
	local conTemp = GetConVar("pdmg_props_only")
	CreateConVar("pdmg_props_only", conTemp:GetInt(),  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Enables damage for prop_physics only")
end
if !ConVarExists("pdmg_ex_wire") then
	CreateConVar("pdmg_ex_wire", '0',  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Disables Damage for wire addon stuff")
else
	local conTemp = GetConVar("pdmg_ex_wire")
	CreateConVar("pdmg_ex_wire", conTemp:GetInt(),  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Disables Damage for wire addon stuff")
end
if !ConVarExists("pdmg_ex_stargate") then
	CreateConVar("pdmg_ex_stargate", '1',  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Disables Damage for Stargate addon stuff")
else
	local conTemp = GetConVar("pdmg_ex_stargate")
	CreateConVar("pdmg_ex_stargate", conTemp:GetInt(),  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Disables Damage for Stargate addon stuff")
end
if !ConVarExists("pdmg_ex_gmod") then
	CreateConVar("pdmg_ex_gmod", '0',  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Disables Damage for GMOD classes")
else
	local conTemp = GetConVar("pdmg_ex_gmod")
	CreateConVar("pdmg_ex_gmod", conTemp:GetInt(),  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Disables Damage for GMOD classes")
end
if !ConVarExists("pdmg_ex_phx_exp") then
	CreateConVar("pdmg_ex_phx_exp", '1',  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Disables Damage for PHX Explosives")
else
	local conTemp = GetConVar("pdmg_ex_phx_exp")
	CreateConVar("pdmg_ex_phx_exp", conTemp:GetInt(),  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Disables Damage for PHX Explosives")
end
if !ConVarExists("pdmg_ex_hl2_exp") then
	CreateConVar("pdmg_ex_hl2_exp", '1',  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Disables Damage for HL2 explosives")
else
	local conTemp = GetConVar("pdmg_ex_hl2_exp")
	CreateConVar("pdmg_ex_hl2_exp", conTemp:GetInt(),  {FCVAR_USERINFO,  FCVAR_ARCHIVE}, "Disables Damage for HL2 explosives")
end